package com.ruoyi.web.controller.system.indexweb;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.IndexCode;
import com.ruoyi.system.domain.IndexTitle;
import com.ruoyi.system.domain.IndexUrl;
import com.ruoyi.system.service.IIndexCodeService;
import com.ruoyi.system.service.IIndexTitleService;
import com.ruoyi.system.service.IIndexUrlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 获取首页信息
 */
@Controller
@RequestMapping("/index")
public class IndexMsgController extends BaseController {

    @Autowired
    private IIndexCodeService indexCodeService;

    @Autowired
    private IIndexTitleService indexTitleService;

    @Autowired
    private IIndexUrlService indexUrlService;

    /**
     * 获取首页数据
     * @return
     */
    @PostMapping("/getMsg")
    @ResponseBody
    public AjaxResult getMsg() {
        List<IndexCode> indexCodes = indexCodeService.selectIndexCodeList(new IndexCode());
        List<IndexTitle> indexTitles = indexTitleService.selectIndexTitleListBySort();
        List<IndexUrl> indexUrls = indexUrlService.selectIndexUrlListBySort();
        JSONObject object = new JSONObject();
        object.put("indexCodes",indexCodes);
        object.put("indexTitles",indexTitles);
        object.put("indexUrls",indexUrls);
        return AjaxResult.success(object);
    }


}
